/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (KeyBinds Manager)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson	<B00137077@studentmail.uws.ac.uk>
*				John Gray			<B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti		<B00104280@studentmail.uws.ac.uk>
*				Euan Hislop			<B00138636@studentmail.uws.ac.uk>
*
*****************************************************************************/
#ifndef CKEYBINDMANAGER_H
#define CKEYBINDMANAGER_H

#include "CKeyBind.h"
#include "CSingleton.h"
#include <cassert>
#include <ctime>
#include <list>
#include "lib.h"
using namespace std;

class CKeyBindManager : public CSingleton < CKeyBindManager >
{
	private:
		std::list<CKeyBind*> m_binds; // DLL of our binds
		bool m_bHasFocus; // boolean as to whether the window has focus currently or not

	public:
		CKeyBindManager ( void ); // constructor
		~CKeyBindManager ( void ); // destructor

		// Binds a key, takes a void callback function, a key and bind type.
		CKeyBind* bindKey ( KeybindCallback CallBack, CKeyBind::eKey key, CKeyBind::eBindType bindType );

		// Proc checks every binds state
		void Proc ( void );

		bool removeBind ( CKeyBind* pKeyBind ); // remove bind by pointer
		bool removeBind ( KeybindCallback CallBack, CKeyBind::eKey key, int bindType ); // remove bind by parameters

		void setHasFocus ( bool bValue )						{ m_bHasFocus = bValue; } // set windows focus state
		bool getHasFocus ( void )								{ return m_bHasFocus; } // return windows focus state

		int getNumOfBinds ( void )								{ return m_binds.size(); } // return the size of m_binds
		bool getKeyState ( CKeyBind::eKey key )					{ return GetAsyncKeyState(key) == 1; } // return state of key
};
#endif